package com.wlanauth.core.criteria;

import org.hibernate.criterion.DetachedCriteria;
/**
 * 通用查询
 * @author zz
 * @date 2012-5-9
 * @email charles.zz.life@gmail.com
 */
public class GeneralCriteria extends DetachedCriteria {
	
	private static final long serialVersionUID = 1L;

	private int start;//开始
	private int limit;//页大小
	private boolean dataOnly = true;//是否查询总数
	
	private GeneralCriteriaQuery query = null;
	
	public GeneralCriteria(Class<?> clazz) {
		super(clazz.getName());
		
	}
	public GeneralCriteria(Class<?> clazz,String alias) {
		super(clazz.getName(),alias);
	}
	
	public int getStart() {
		return start;
	}



	public void setStart(int start) {
		this.start = start;
	}



	public int getLimit() {
		return limit;
	}



	public void setLimit(int limit) {
		this.limit = limit;
	}

	public boolean isDataOnly() {
		return dataOnly;
	}

	public void setDataOnly(boolean dataOnly) {
		this.dataOnly = dataOnly;
	}
	
	public <T extends Object> GeneralCriteriaResult<T> executeQuery(){
		return getCriteriaQuery().execute(this);
	}
	public void initialize(Object obj){
		this.getCriteriaQuery().initialize(obj);
	}
	
	public GeneralCriteriaQuery getCriteriaQuery(){
		if(this.query == null){
			this.query = new GeneralCriteriaQuery();
		}
		return this.query;
	}

}
